package org.anyin.gitee.cloud.center.base.repository;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.conditions.query.QueryChainWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.anyin.gitee.cloud.center.base.mapper.SysRouteMapper;
import org.anyin.gitee.cloud.center.base.model.SysRouteModel;
import org.anyin.gitee.cloud.lib.core.web.BaseRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class SysRouteRepository extends BaseRepository<SysRouteMapper, SysRouteModel> {

    public boolean existPath(String path, Long id){
        Boolean exist = baseMapper.existPath(path, id);
        return exist != null && exist;
    }

    public boolean existRouteName(String routeName, Long id){
        Boolean exist = baseMapper.existRouteName(routeName, id);
        return exist != null && exist;
    }

    public Page<SysRouteModel> page(Page<SysRouteModel> page, String path, String routeName){
        QueryWrapper<SysRouteModel> wrapper = new QueryWrapper<>();
        wrapper.like("path", path);
        wrapper.like("route_name", routeName);
        return this.page(page, wrapper);
    }

    public List<SysRouteModel> all(){
        return baseMapper.selectList(new QueryWrapper<>());
    }
}
